import { createStore, applyMiddleware, compose  } from 'redux';
import thunk from 'redux-thunk';
import reducer from './reducer';


// copy from https://github.com/zalmoxisus/redux-devtools-extension
// to make 'store' compatible with thunk and redux-devtool
const composeEnhancers =
    typeof window === 'object' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
        window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
            // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
        }) : compose;

const enhancer = composeEnhancers(
    // use the thunk as middleware
    applyMiddleware(thunk)
);


const store = createStore(
    // use the imported reducer as a reducer
    reducer,
    enhancer
);

export default store;